
new Vue({
    el:'#main',
    data:{
        more:false,
        account:{

        },
    },
    methods:{
        showMore:function(){
            if (this.account.accountIdcardNo == undefined || this.account.accountIdcardNo.length !=18){
                layer.msg("请正确填写身份证号");
                return;
            }
            this.more = !this.more;
            let no = this.account.accountIdcardNo;
            no = no.substring(6,14);
            let year = no.substring(0,4);
            let month = no.substring(4,6);
            let day = no.substring(6);
            this.account.accountBirthdate=year+"-"+month+"-"+day;
        },

        doInsert:function(){
            if (this.account.accountLoginPasswd != this.account.accountReLoginPasswd){
                layer.msg("输入密码不一致");
                return;
            }
            if (this.account.accountRealName == undefined){
                layer.msg("姓名不能为空");
                return;
            }
            if (this.account.accountIdcardNo == undefined || this.account.accountIdcardNo.length !=18){
                layer.msg("请正确填写身份证号");
                return;
            }
            if (this.account.accountLoginName == undefined){
                layer.msg("登录账号不能为空");
                return;
            }
            if (this.account.accountLoginPasswd == undefined){
                layer.msg("登录密码不能为空");
                return;
            }
            if (this.account.accountTelephone == undefined){
                layer.msg("电话不能为空");
                return;
            }
            axios({
                url: `manager/account/selectByCardNo`,
                params: {"cardNo":this.account.accountIdcardNo}
            }).then(response =>{
                if (response.data.msg == '1'){
                    layer.msg("保存失败，该身份证已经开通过账务账号！")
                }else {
                    axios({
                        method:"post",
                        url: `manager/account/doInsert`,
                        data: this.account
                    }).then(res =>{
                        parent.layer.message=res.data.msg;
                        this.close();
                    }).catch(error=>{
                        layer.msg(error.msg)
                    })
                }
            }).catch(error=>{
                layer.msg(error.msg)
            })
        },
        close:function () {
            let index = parent.layer.getFrameIndex(window.name); //获取窗口索引
            parent.layer.close(index);//通过父窗口layer对象关闭子窗口

        }

    },


})